package dome1;

import java.util.Arrays;
import java.util.Random;

public class Text {
    public static void main10(String[] args) {
        int[] arr = {5,3,2,4,5,2,1,40};
        Sort.bucketSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main9(String[] args) {
        int[] arr = {5,3,2,4,5,2,1,40};
        Sort.countSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main8(String[] args) {
        int[] arr = {5,3,2,4,1};
        Sort.mergeSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main7(String[] args) {
        int[] array = new int[10_0000];
        readyDataOrder(array);
        InsertOrder(array);
        ShellOrder(array);
        selectOrder(array);
        select2Order(array);
        heaptOrder(array);
        bubbleOrder(array);
        quickOrder(array);
        mergeOrder(array);
    }

    public static void mergeOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.mergeSort(array);
        long end = System.currentTimeMillis();
        System.out.println("归并排序耗时参考：" + (end - start));
    }

    public static void quickOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.quickSort(array);
        long end = System.currentTimeMillis();
        System.out.println("快速排序耗时参考：" + (end - start));
    }
    public static void main6(String[] args) {
        int[] arr = {5,3,2,4,1};
        Sort.quickSort2(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void bubbleOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.bubbleSort(array);
        long end = System.currentTimeMillis();
        System.out.println("冒泡排序耗时参考：" + (end - start));
    }
    public static void main5(String[] args) {
//        int[] arr = {5,3,2,4,1};
        int[] arr = {1,2,3,4,5};
        Sort.bubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void selectOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.selectSort(array);
        long end = System.currentTimeMillis();
        System.out.println("选择排序耗时参考：" + (end - start));
    }

    public static void select2Order(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.select2Sort(array);
        long end = System.currentTimeMillis();
        System.out.println("选择排序2耗时参考：" + (end - start));
    }

    public static void heaptOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.heapSort(array);
        long end = System.currentTimeMillis();
        System.out.println("堆排序耗时参考：" + (end - start));
    }

    public static void main4(String[] args) {
        int[] arr = {5,3,2,4,1};
//        Sort.createHeap(arr);
//        System.out.println(Arrays.toString(arr));
        Sort.heapSort(arr);
        System.out.println(Arrays.toString(arr));

    }
    public static void main3(String[] args) {
        int[] arr = {5,3,2,4,1};
//        int[] arr = {1,3,2,5,4};
        Sort.select2Sort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void readyDataOrder(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(100000);
        }
    }

    public static void InsertOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.insertSort(array);
        long end = System.currentTimeMillis();
        System.out.println("插入排序耗时参考：" + (end - start));
    }

    public static void ShellOrder(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.shellSort(array);
        long end = System.currentTimeMillis();
        System.out.println("希尔排序耗时参考：" + (end - start));
    }

    public static void main2(String[] args) {
        int[] array = new int[100000];
        readyDataOrder(array);
        InsertOrder(array);
        ShellOrder(array);
    }
    public static void main1(String[] args) {
        int[] arr = {5,3,2,1,4};
//        Sort.insertSort(arr);
//        System.out.println(Arrays.toString(arr));
        Sort.shellSort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
